
<?php

require_once '/DAL/DbHelper.php';
require_once '/Model/ApplicationEntity.php';

/**
 * The functions for seretary
 * @author Kun.Huang
 * Date : 27/5/2013
 */
class Controller_Secretary {

    public $ControllerName = 'Controller_Secretary';
    public $DbHelper = null;
    public $UserEntity = null;

    /**
     *  the default Constructor
     */
    public function __construct() {
        $this->DbHelper = new DbHelper();
        $this->UserEntity = $_SESSION["UserEntity"];
    }

    /**
     * Return the Advisor list in School
     * @param type $SchoolID
     * @return type
     */
    public function getAdvisorList() {
        $strSQL = "call Proc_Busi_Secretary_GetAdevisorList(?)";
        $parameters[] = $this->UserEntity->SchoolID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    public function AssignAdvisor($entity) {
        $strSQL = "call Proc_Busi_Secretary_AssignAdvisor(?,?,?,?,?,?,?,?)";
        $parameters[] = $entity->rowApplicationID;
        $parameters[] = $entity->rowHandleSchoolID;
        $parameters[] = $entity->rowStateID;
        $parameters[] = $entity->rowActionUserID;
        $parameters[] = $entity->newActionUserID;
        $parameters[] = $entity->newActionStateID;
        $parameters[] = $entity->newActionCommnet;
        $parameters[] = $entity->newAdvisorID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    /**
     * Accept Application
     * @param type $entity
     * @return type
     */
    public function AcceptApplication($entity) {
        $strSQL = "call Proc_Busi_Secretary_Accept(?,?,?,?,?,?)";
        $parameters[] = $entity->rowApplicationID;
        $parameters[] = $entity->rowHandleSchoolID;
        $parameters[] = $entity->rowStateID;
        $parameters[] = $entity->rowActionUserID;
        $parameters[] = $entity->newActionUserID;
        $parameters[] = $entity->newActionStateID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    public function QuerySummary($SchoolID) {
        $strSQL = "call Proc_Busi_Secretary_QuerySummary(?)";
        $parameters[] = $SchoolID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    public function QuerySummaryDetail($SchoolID, $ApplicationID) {
        $strSQL = "call Proc_Busi_Secretary_QueryAccordionDetail(?,?)";
        $parameters[] = $SchoolID;
        $parameters[] = $ApplicationID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

}

?>
